package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @author shaozn
 */

public enum DeviceType implements IEnum<Integer> {
    /**
     * 称重设备
     */
    WEIGHT(1, "称重"),
    /**
     * 扫码设备
     */
    SCANNER(2, "SM"),
    /**
     * LED 显示
     */
    LED(3, "LED"),
    /**
     * 机械手
     */
    MACHINE_HAND(4, "机械手"),
    /**
     * AGV 设备
     */
    AGV(5, "AGV"),


    REMARK(6, "其他");
    @EnumValue
    private Integer deviceType;
    @JsonValue
    private String description;

    DeviceType(int deviceType, String description) {
        this.deviceType = deviceType;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    @Override
    public Integer getValue() {
        return deviceType;
    }


    public static DeviceType parsePlcDeviceType(int deviceType) {
        DeviceType[] Types = DeviceType.values();
        for (DeviceType type : Types) {
            if (type.deviceType == deviceType) {
                return type;
            }
        }
        throw new IllegalArgumentException("设备类型参数错误:" + deviceType);
    }
}
